<template>
    <div class="el-mr-mh-topSearch">
        <ul>
        <li style="font-size:17px;color:black;">条码:</li>
        <li>
          <el-input
            ref="saomaInput"
            size="mini"
            v-model="inTiaoma"
            placeholder="请输入缓存箱/托盘码/条码"
            @keyup.enter.native="saomaEnter($event)"
          ></el-input>
        </li>
        <slot></slot>
      </ul>
    </div>
</template>
<script>

export default {
    name:'TopSearch',
    data(){
      return{
        inTiaoma:'',
      }
    },
    methods:{
      saomaEnter(){
        this.$parent.scanning()
        // 全选
        this.$refs.saomaInput.select()
        // console.log(e.currentTarget,'全选')
        // console.log('扫码回车绑定',this.inTiaoma)
      },
      openScan(){
        // 扫码聚焦
        this.$refs.saomaInput.focus()
      },
      // 聚焦全选内容
      // selectAll(e){
      //   console.log(e.target.methods,'全选')
      //   // e.target.select()
      //   this.$refs.saomaInput.select()
      // },
      makeTmNull(){
        this.inTiaoma = ''
      }

    },
    watch:{
      inTiaoma(oldValue, newValue) {
        this.$bus.$emit('saoma',this.inTiaoma)
      }
    },
    mounted(){
      // 进入页面让input聚焦
      this.$refs.saomaInput.focus();
      this.$bus.$on("resetScanInput",()=>{
        this.inTiaoma = "";
      })
    }
}
</script>
<style scoped>
.el-mr-mh-topSearch {
  width: 100%;
  height: 40px;
  /* border: 1px solid rgb(204, 204, 204); */
  padding: 0 2px;
}
.el-mr-mh-topSearch ul li {
  height: 35px;
  float: left;
  margin-right: 20px;
  line-height: 37px;
  font-size: 14px;
}
</style>